package com.smp.dsandroidtester.ds;

public abstract class NativeStackBase extends DSNativeWrapper {
	private long mNativeHandle;

	public NativeStackBase() {
		super();
	}
	
	protected void initAsIntArrayStack(int aSize, boolean abConcurrent) {
		mNativeHandle = createIntArrayStack(aSize, abConcurrent);
	}

	protected void initAsIntLinkedStack(int aSize, boolean abConcurrent) {
		mNativeHandle = createIntLinkedStack(aSize, abConcurrent);
	}
	
	@Override
	protected void finalize() throws Throwable {
		if(mNativeHandle != 0) {
			destroyDS(mNativeHandle);
		}
		super.finalize();
	}
	
	public void push(int anData) {
		pushIntStack(mNativeHandle, anData);
	}
	
	public int pop() {
		return popIntStack(mNativeHandle);
	}
	
	public boolean canPush() {
		return canPushIntStack(mNativeHandle);
	}
	
	public boolean canPop() {
		return canPopIntStack(mNativeHandle);
	}
	
	public int getDataCount() {
		return getDataCountIntStack(mNativeHandle);
	}
}
